package com.block.merchant.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.block.common.constant.AppRspCodeConstant;
import com.block.common.vo.ResponseVo;
import com.block.db.entity.MerchantDetailInfo;
import com.block.db.mapper.MerchantDetailInfoMapper;
import com.block.merchant.model.vo.MerchantInfoVO;
import com.block.merchant.model.vo.PersonInfoVO;
import com.block.merchant.service.IMerchantDetailInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 商户详情信息 服务实现类
 * </p>
 *
 * @author 
 * @since 2024-04-07
 */
@Service
public class MerchantDetailInfoServiceImpl extends ServiceImpl<MerchantDetailInfoMapper, MerchantDetailInfo> implements IMerchantDetailInfoService {

    @Override
    public MerchantDetailInfo getEntityByInfoId(Integer infoId) {
        return this.getById(infoId);
    }

    @Override
    public ResponseVo getDetailInfoByInfoId(String infoId) {

        MerchantDetailInfo merchantDetailInfo = this.getEntityByInfoId(Integer.valueOf(infoId));

        MerchantInfoVO merchantInfoVO = new MerchantInfoVO();
        merchantInfoVO.setInfoId(merchantDetailInfo.getInfoId());
        merchantInfoVO.setProductLogo(merchantDetailInfo.getProductLogo());
        merchantInfoVO.setProductName(merchantDetailInfo.getProductName());
        merchantInfoVO.setCompanyName(merchantDetailInfo.getCompanyName());
        merchantInfoVO.setLabelInfo(merchantDetailInfo.getLabelInfo());
        merchantInfoVO.setAddressInfo(merchantDetailInfo.getAddressInfo());
        merchantInfoVO.setIntroInfo(merchantDetailInfo.getIntroInfo());
        merchantInfoVO.setPositionInfo(merchantDetailInfo.getPositionInfo());

        // todo 查询客服人员信息
        PersonInfoVO personInfoVO = new PersonInfoVO();
        personInfoVO.setUserId(1);
        personInfoVO.setUsername("赵子涵");
        personInfoVO.setUserImage("https://source.renxinhua.cn/pro/logo/prologo_b3512edf-4753-4bbf-a71c-9193a0c0d33f.jpg");
        personInfoVO.setPostName("客服经理");
        personInfoVO.setLastReply("1小时前");
        personInfoVO.setRepayNumber("20+");

        JSONObject returnData = new JSONObject();
        returnData.put("merchantInfo", merchantInfoVO);
        returnData.put("personInfo", personInfoVO);

        return new ResponseVo(AppRspCodeConstant.SUCCESS, returnData);
    }
}
